package org.SocketStream;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;


public class SocketClient {
	SocketStream stream=null;
   public void connect(SocketAddress addr){
	   try {

		Socket s = new Socket (addr.GetAddress(),addr.GetPort());
		//InetAddress address=InetAddress.getByName(addr.GetAddress());  
		//s.connect(new InetSocketAddress(address, addr.GetPort()));
		stream=SocketStreamFactory.getInstance().getSocketStream(s);
			

	} catch (UnknownHostException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
   }
   
   public SocketStream getStream() {
	return stream;
}

public void setStream(SocketStream stream) {
	this.stream = stream;
}

public void close(){
	   if(stream!=null){
		   stream.Close();
	   }
   }
}
